Garbage collection improves programmer productivity because it frees programmers from having to consider object lifetimes and freeing memory and it also prevents temporal memory safety errors, i.e. uses of memory after it has been freed, which may lead to safety breaches. In contrast, manual memory management often delivers better performance, e.g. because a programmer can promptly deallocate objects and exploit their knowledge of object lifetimes to free objects at specific program locations, but is often unsafe and can lead to system crashes or security vulnerabilities because freeing memory may create dangling pointers, i.e. pointers to memory that has been freed, and dereferences of dangling pointers lead to undefined behavior.
The embodiments described below are not limited to implementations which solve any or all of the disadvantages of known methods of memory management.